'use strict';

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  const { router, controller, middleware } = app;
  const { auth } = middleware;

  // 上传
  router.post('/api/upload/file', controller.uploadcos.cos);
  // 后台用户
    router.resources('adminUser', '/api/admin/user', controller.adminUser);
  // 后台角色
  //   router.get('/api/role/list', controller.role.allList);
  //   router.resources('role', '/api/role', controller.role);
  // news
    router.get('/api/news/list', controller.news.allList);
    router.resources('news', '/api/news', controller.news);
    // banner
    router.get('/api/banner/list', controller.banner.allList);
    router.resources('banner', '/api/banner', controller.banner);
    // 后台分类
    router.get('/api/category/list', controller.courseCategory.allList);
    router.resources('category', '/api/category', controller.courseCategory);
    // 课程
    router.get('/api/course/list', controller.course.allList);
    router.resources('course', '/api/course', controller.course);
    // 课程章节
    router.get('/api/courseChapter/list', controller.courseModules.allList);
    router.resources('courseChapter', '/api/courseChapter', controller.courseModules);
    // 课程内容
    router.get('/api/courseItem/list', controller.courseItem.allList);
    router.resources('courseItem', '/api/courseItem', controller.courseItem);
    // 问题
    router.get('/api/question/list', controller.question.allList);
    router.resources('question', '/api/question', controller.question);
    // 问题选项
    router.get('/api/questionOption/list', controller.questionOption.allList);
    router.resources('questionOption', '/api/questionOption', controller.questionOption);
    // 用户练习记录
    router.post('/api/userPracticeRecord/submit', controller.userPracticeRecord.submitUserPracticeRecord);
    router.get('/api/userPracticeRecord/list', controller.userPracticeRecord.allList);
    router.resources('userPracticeRecord', '/api/userPracticeRecord', controller.userPracticeRecord);
    // 用户练习
    router.get('/api/userPractice/list', controller.userPractice.allList);
    router.resources('userPractice', '/api/userPractice', controller.userPractice);
    // 考试记录
    router.get('/api/userExamRecord/list', controller.userExamRecord.allList);
    router.resources('userExamRecord', '/api/userExam', controller.userExamRecord);
    // 考试
    router.get('/api/userExam/list', controller.userExam.allList);
    router.resources('userExam', '/api/userExam', controller.userExam);

    // 登录
    router.post('/api/user/login', controller.user.login);
    router.post('/api/user/register', controller.user.create);

    router.resources('user', '/api/user', controller.user);
    // product
  // /product/list2

  router.get('/api/product/list2', controller.product.allList2);
  router.get('/api/product/list', controller.product.allList);
    router.resources('product', '/api/product', controller.product);
  // policy
  router.get('/api/policy/list', controller.policy.allList);
  router.resources('policy', '/api/policy', controller.policy);
    // 开始抽奖
  router.post('/api/lotteryRecord/start', controller.lotteryRecord.start);
  router.post('/api/lotteryRecord/updateProduct', controller.lotteryRecord.updateProduct);
    // 抽奖记录
    router.get('/api/lotteryRecord/list', controller.lotteryRecord.allList);
    router.resources('lotteryRecord', '/api/lotteryRecord', controller.lotteryRecord);
    // dailyLottery
    router.get('/api/dailyLottery/list', controller.dailyLottery.allList);
    router.resources('dailyLottery', '/api/dailyLottery', controller.dailyLottery);
};
